public class Solution799 {
    public double champagneTower(int poured, int query_row, int query_glass) {
        int cur=0;
        double[] f=new double[200];
        f[0]=poured;
        while (cur<query_row){
            cur++;
            double[] g=new double[200];
            for (int i=0;i<=cur;i++){
                if (f[i]>1){
                    double t=f[i]-1;
                    g[i]+=t/2;
                    g[i+1]+=t/2;
                }
            }
            f=g;
        }
        return Math.min(1,f[query_glass]);
    }

    public static void main(String[] args) {
        System.out.println(new Solution799().champagneTower(100000009,33,17));
    }
}
